*/
#include "defs.h"
-#if CETUS
#include "coldsync/palm.h"
#include "coldsync/pdb.h"
-typedef struct {
- unsigned char data[4];
-} pdb_32;
-
-typedef struct {
- unsigned char data[2];
-} pdb_16;
-
-
struct record {
char type;
char ID[16]; /* Zero-terminated string. */
fclose(file_out);
}
-/*
- * Read 4 bytes in big-endian. Return as "int" in native endianness.
- */
-int
-read4(pdb_32 *p)
-{
- char *i = (char *) p;
- return i[0] << 24 | i[1] << 16 | i[2] << 8 | i[3];
-}
-
-void
-write4(pdb_32 *pp, unsigned i)
-{
- char *p = (char *)pp;
-
- p[0] = (i >> 24) & 0xff;
- p[1] = (i >> 16) & 0xff;
- p[2] = (i >> 8) & 0xff;
- p[3] = i & 0xff;
-}
-
static void
data_read(void)
{
rec = (struct record *) pdb_rec->data;
wpt_tmp->shortname = strdup(rec->ID);
wpt_tmp->description = strdup(rec->name);
- wpt_tmp->position.altitude.altitude_meters = read4(&rec->elevation) / 100.0;
+ wpt_tmp->position.altitude.altitude_meters = pdb_read4(&rec->elevation) / 100.0;
- wpt_tmp->position.longitude.degrees = read4(&rec->longitude) / 10000000.0;
- wpt_tmp->position.latitude.degrees = read4(&rec->latitude) / 10000000.0;
+ wpt_tmp->position.longitude.degrees = pdb_read4(&rec->longitude) / 10000000.0;
+ wpt_tmp->position.latitude.degrees = pdb_read4(&rec->latitude) / 10000000.0;
if (rec->year != 0xff) {
struct tm tm = {0};
time_t tval;
rec->year = 0xff;
}
- write4(&rec->longitude, wpt->position.longitude.degrees * 10000000.0);
- write4(&rec->latitude, wpt->position.latitude.degrees * 10000000.0);
- write4(&rec->elevation, wpt->position.altitude.altitude_meters * 100.0);
+ pdb_write4(&rec->longitude, wpt->position.longitude.degrees * 10000000.0);
+ pdb_write4(&rec->latitude, wpt->position.latitude.degrees * 10000000.0);
+ pdb_write4(&rec->elevation, wpt->position.altitude.altitude_meters * 100.0);
opdb_rec = new_Record (0, 0, ct++, sizeof(*rec), (const ubyte *)rec);
data_read,
data_write,
};
-#else
-ff_vecs_t cetus_vecs;
-#endif
ff_vecs_t *find_vec(char *);
void printposn(coord *c, int is_lat);
+
+/*
+ * Data types for Palm/OS files.
+ */
+typedef struct {
+ unsigned char data[4];
+} pdb_32;
+
+typedef struct {
+ unsigned char data[2];
+} pdb_16;
+
+/*
+ * Protypes for Palm/OS helpers.
+ */
+
+int pdb_read2(pdb_16 *p);
+int pdb_read4(pdb_32 *p);
+void pdb_write2(pdb_16 *pp, unsigned i);
+void pdb_write4(pdb_32 *pp, unsigned i);
vfprintf(stderr, fmt, ap);
exit(1);
}
+
+/*
+ * Read 4 bytes in big-endian. Return as "int" in native endianness.
+ */
+int
+pdb_read4(pdb_32 *p)
+{
+ char *i = (char *) p;
+ return i[0] << 24 | i[1] << 16 | i[2] << 8 | i[3];
+}
+
+void
+pdb_write4(pdb_32 *pp, unsigned i)
+{
+ char *p = (char *)pp;
+
+ p[0] = (i >> 24) & 0xff;
+ p[1] = (i >> 16) & 0xff;
+ p[2] = (i >> 8) & 0xff;
+ p[3] = i & 0xff;
+}